# encoding=utf-8
import os
from hashlib import md5

def GetFileId(filename):
    fm = md5()
    sm = md5()
    if not os.path.isfile(filename):
        print( 'No such file: %s' % filename )
        return ''
    file = open( filename, 'r' )
    fm.update( file.read() )
    file.close()
    sm.update( str(os.stat( filename ).st_size) )
    return fm.hexdigest() + sm.hexdigest() 

def GetValidFileIndex(strFileNameWithD):
    i = 0
    while(os.path.exists(strFileNameWithD % i)):
        i = i + 1
    return i
